package com.yellowpage.omc.ability.service;

import java.util.List;
import java.util.Map;

import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;

import com.yellowpage.white.common.Constants;
import com.yellowpage.white.common.PageRender;
import com.yellowpage.white.dao.QueryAssistantSQL;
import com.yellowpage.white.service.BaseServiceImpl;

import com.yellowpage.omc.ability.data.AppInterfaceParamValue;
import com.yellowpage.omc.ability.dao.AppInterfaceParamValueDao;

public class AppInterfaceParamValueServiceImpl extends BaseServiceImpl implements AppInterfaceParamValueService {
	  private AppInterfaceParamValueDao appInterfaceParamValueDao;
	
	  public void setAppInterfaceParamValueDao(AppInterfaceParamValueDao appInterfaceParamValueDao) {
		  this.appInterfaceParamValueDao = appInterfaceParamValueDao;
	  }
	
	
	  /* Smooth generate Method */ 
	  public AppInterfaceParamValue getAppInterfaceParamValue(Long id){
	      return appInterfaceParamValueDao.get(id);
	  }
	  
    public List<AppInterfaceParamValue> getAllAppInterfaceParamValue(){
        return appInterfaceParamValueDao.getAll();
    }
    
    public List<Map> queryAppInterfaceParamValueByPage(Map queryMap, PageRender pageRender) {		
        
		QueryAssistantSQL sqlAssistant = baseDao.newQueryAssistantSQL(
				"SELECT a.PARAM_VALUE_ID , a.INTERFACE_PARAM_ID , a.PARAM_VALUE_DIAPLAY , a.PARAM_VALUE , a.NOTE ," +
				"       (select display_name from CA_USER where user_id = a.LAST_UPDATE_USER) as last_update_user, " +
				"       (select display_name from CA_USER where user_id = a.CREATE_USER) as create_user, " +
				"        a.CREATE_TIME ,  a.LAST_UPDATE_TIME , a.STATUS , (SELECT display_name FROM CA_USER WHERE user_id = a.LAST_SYNCHRONIZATION_USER) AS last_synchronization_user,a.LAST_SYNCHRONIZATION_TIME FROM OMC_INTERFACE_PARAM_VALUE a WHERE 1=1 ")
				    			.addCondition(" and PARAM_VALUE_ID = :paramValueId ")
							    			.addCondition(" and INTERFACE_PARAM_ID = :interfaceParamId ")
							    			.addCondition(" and PARAM_VALUE_DIAPLAY = :paramValueDiaplay ")
							    			.addCondition(" and PARAM_VALUE = :paramValue ")
							    			.addCondition(" and NOTE = :note ")
							    			.addCondition(" and CREATE_USER = :createUser ")
							    		    .addCondition(" and date_format(CREATE_TIME,'%Y-%m-%d') =  :createTime  ")
		    				    			.addCondition(" and LAST_UPDATE_USER = :lastUpdateUser ")
							    		    .addCondition(" and date_format(LAST_UPDATE_TIME,'%Y-%m-%d') =  :lastUpdateTime  ")
		    				    			.addCondition(" and STATUS = :status ")
		    				    			.addCondition(" and LAST_SYNCHRONIZATION_USER = :LastSynchronizationUser ")
							    			.addCondition(" and LAST_SYNCHRONIZATION_TIME = :LastSynchronizationTime ")
							    ;
		    

		List<Map> resultList = sqlAssistant.queryByPage(
				baseDao.getConnection(), queryMap, pageRender);

		return resultList;
	}
    
    
    public void saveAppInterfaceParamValue(AppInterfaceParamValue appInterfaceParamValue){
        appInterfaceParamValueDao.save(appInterfaceParamValue);
    }
    
	  public void updateAppInterfaceParamValue(AppInterfaceParamValue appInterfaceParamValue){
	      appInterfaceParamValueDao.update(appInterfaceParamValue);
	  }
	  
	  public void delete(List deleteList){
	      appInterfaceParamValueDao.remove(deleteList);
	  }
	  
	  
	 
	
}	